import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.wb.swt.SWTResourceManager;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;


public class BudgetBuoy extends Composite {

	private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
	private Label lblBudgetbuoy;
	private Label lblNewLabel;

	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public BudgetBuoy(Composite parent, int style) {
		super(parent, style);
		addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				toolkit.dispose();
			}
		});
		toolkit.adapt(this);
		toolkit.paintBordersFor(this);
		setLayout(new FormLayout());
		
		lblBudgetbuoy = new Label(this, SWT.NONE);
		lblBudgetbuoy.setBackground(SWTResourceManager.getColor(51, 204, 255));
		lblBudgetbuoy.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.NORMAL));
		FormData fd_lblBudgetbuoy = new FormData();
		fd_lblBudgetbuoy.top = new FormAttachment(0, 10);
		fd_lblBudgetbuoy.left = new FormAttachment(0, 10);
		lblBudgetbuoy.setLayoutData(fd_lblBudgetbuoy);
		toolkit.adapt(lblBudgetbuoy, true, true);
		lblBudgetbuoy.setText("\u00A9BudgetBuoy");
		
		Composite composite = new Composite(this, SWT.NONE);
		FormData fd_composite = new FormData();
		fd_composite.bottom = new FormAttachment(100, -26);
		fd_composite.left = new FormAttachment(lblBudgetbuoy, 0, SWT.LEFT);
		fd_composite.right = new FormAttachment(100, -23);
		composite.setLayoutData(fd_composite);
		toolkit.adapt(composite);
		toolkit.paintBordersFor(composite);
		
		Composite composite_1 = new Composite(this, SWT.NONE);
		composite_1.setLayout(new FillLayout(SWT.HORIZONTAL));
		FormData fd_composite_1 = new FormData();
		fd_composite_1.right = new FormAttachment(100, -33);
		fd_composite_1.left = new FormAttachment(0);
		fd_composite_1.top = new FormAttachment(lblBudgetbuoy, 3);
		composite_1.setLayoutData(fd_composite_1);
		toolkit.adapt(composite_1);
		toolkit.paintBordersFor(composite_1);
		
		Composite composite_2 = new Composite(this, SWT.NONE);
		fd_composite.top = new FormAttachment(composite_2, 6);
		composite_2.setLayout(new GridLayout(6, false));
		FormData fd_composite_2 = new FormData();
		fd_composite_2.top = new FormAttachment(lblBudgetbuoy, 6);
		fd_composite_2.left = new FormAttachment(lblBudgetbuoy, 10, SWT.LEFT);
		fd_composite_2.bottom = new FormAttachment(100, -296);
		fd_composite_2.right = new FormAttachment(100, -23);
		
		Button btnAdd = new Button(composite, SWT.NONE);
		btnAdd.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				Button b = (Button)e.getSource();
				
				String[] subMenu = new String[10];
				subMenu[0] = "-= Main menu > Add Entry =-";
				subMenu[1] = "Select type of entry:";
				subMenu[2] = "1. Expense";
				subMenu[3] = "2. Expense with receipt (not as of V0.1)";
				subMenu[4] = "3. Loan Payments";
				subMenu[5] = "4. Income";
				subMenu[6] = "5. Cash Loan";
				subMenu[7] = "";
				subMenu[8] = "Option: ";
				
				String newLine = System.getProperty("line.separator");
				String printMenu = "";
				for(int i=0; i<9; i++){
					printMenu += subMenu[i] +newLine;
				}
				
				lblNewLabel.setText(printMenu);

			}
		});
		btnAdd.setImage(SWTResourceManager.getImage("C:\\Users\\SilingNUS\\Desktop\\Button Add Icon.jpg"));
		btnAdd.setBounds(10, 10, 75, 58);
		toolkit.adapt(btnAdd, true, true);
		
		Button btnDelete = new Button(composite, SWT.NONE);
		btnDelete.setImage(SWTResourceManager.getImage("C:\\Users\\SilingNUS\\Desktop\\deleteI.png"));
		btnDelete.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnDelete.setBounds(10, 82, 75, 51);
		toolkit.adapt(btnDelete, true, true);
		
		Button btnReport = new Button(composite, SWT.NONE);
		btnReport.setBounds(10, 152, 75, 25);
		toolkit.adapt(btnReport, true, true);
		btnReport.setText("Report");
		
		Button btnAlertSettings = new Button(composite, SWT.NONE);
		btnAlertSettings.setBounds(10, 188, 75, 25);
		toolkit.adapt(btnAlertSettings, true, true);
		btnAlertSettings.setText("Alert Settings");
		
		Button btnManage = new Button(composite, SWT.NONE);
		btnManage.setBounds(10, 219, 75, 25);
		toolkit.adapt(btnManage, true, true);
		btnManage.setText("Manage");
		
		lblNewLabel = new Label(composite, SWT.NONE);
		lblNewLabel.setBackground(SWTResourceManager.getColor(51, 204, 255));
		lblNewLabel.setBounds(123, 10, 430, 234);
		toolkit.adapt(lblNewLabel, true, true);
		lblNewLabel.setText("output");
		composite_2.setLayoutData(fd_composite_2);
		toolkit.adapt(composite_2);
		toolkit.paintBordersFor(composite_2);
		
		Button btnUndo = new Button(composite_2, SWT.NONE);
		btnUndo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		toolkit.adapt(btnUndo, true, true);
		btnUndo.setText("Undo");
		
		Button btnRedo = new Button(composite_2, SWT.NONE);
		toolkit.adapt(btnRedo, true, true);
		btnRedo.setText("Redo");
		
		Button btnHome = new Button(composite_2, SWT.NONE);
		btnHome.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		toolkit.adapt(btnHome, true, true);
		btnHome.setText("Home");
		
		Button btnExportimport = new Button(composite_2, SWT.NONE);
		btnExportimport.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
		btnExportimport.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnExportimport.setImage(SWTResourceManager.getImage("C:\\Users\\SilingNUS\\Desktop\\Export_Import.gif"));
		toolkit.adapt(btnExportimport, true, true);
		btnExportimport.setText("Export/Import");
		
		Button btnReceiptTracking = new Button(composite_2, SWT.NONE);
		btnReceiptTracking.setImage(SWTResourceManager.getImage("C:\\Users\\SilingNUS\\Desktop\\receipt1.png"));
		GridData gd_btnReceiptTracking = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
		gd_btnReceiptTracking.widthHint = 161;
		gd_btnReceiptTracking.heightHint = 53;
		btnReceiptTracking.setLayoutData(gd_btnReceiptTracking);
		toolkit.adapt(btnReceiptTracking, true, true);
		btnReceiptTracking.setText("Receipt Tracking");
		
		Button btnSearch = new Button(composite_2, SWT.NONE);
		btnSearch.setImage(SWTResourceManager.getImage("C:\\Users\\SilingNUS\\Desktop\\search.png"));
		btnSearch.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
		toolkit.adapt(btnSearch, true, true);
		btnSearch.setText("Search");

	}
	
	public static void main(String[] args){
	    Display display = new Display();
	    Shell shell = new Shell(display);
	    BudgetBuoy budgetbuoy = new BudgetBuoy(shell, SWT.NONE);
	    budgetbuoy.pack();
	    shell.pack();
	    shell.open();
	    while(!shell.isDisposed()){
	        if(!display.readAndDispatch()) display.sleep();
	    }
	}
}
